﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace de.wolfmarco.pas.Shared.Helper
{
    public static class DesignerHelper
    {
        public static bool IsInDesignMode(DependencyObject dependencyObject)
        {
            bool isInDesignMode = false;
            DependencyObject currentObject = dependencyObject;
            FrameworkElement element = currentObject as FrameworkElement;

            while (isInDesignMode == false && currentObject != null)
            {
                isInDesignMode = DesignerProperties.GetIsInDesignMode(dependencyObject);

                if (element != null)
                {
                    currentObject = element.Parent;
                    element = currentObject as FrameworkElement;
                }
            }

            return isInDesignMode;
        }

    }
}
